/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package chat.server;

import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author cibervn
 */
public class Manager {
    /**
     * A map of camarero
     */
    private Map<String, Camarero> camareros;

    public Manager() {
        camareros = new HashMap<String, Camarero>();
    }

    /**
     * Add a Camarero to serve a client
     * @param name
     * @param camarero
     * @return true if can add, false otherwise
     */
    public boolean addCamarero(Camarero camarero) {
        if (!camareros.containsKey(camarero.getClientName())) {
            camareros.put(camarero.getClientName(), camarero);
            return true;
        }
        return false;
    }

    /**
     * Send email from a client to another
     * @param from
     * @param to
     * @param message
     * @return
     */
    public boolean send(String from, String to, String message) {
        Camarero camarero = camareros.get(to);
        if (camarero != null) {
            camarero.receive(from, message);
            return true;
        }
        return false;
    }
}
